package com.yoyo.itravel.dao;

import com.yoyo.itravel.bean.FlightTicketType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;
import java.util.List;

/**
 * 机票类型表相关操作接口【持久层】
 * @Author: liuchaojie
 * @Date 2020/6/17 16:37
 */
@Repository
public interface IFlightTicketTypeDao {
    /**
     * 新增机票类型
     * @param flightTicketType
     * @return
     * @throws SQLException
     */
    @Insert("insert into tb_flight_ticket_type(ticketTypeId, flightId, ticketTypeName, tankType, initPrice, discount, luggageWeight, isCancel, cancelRule) " +
            " values(#{ticketTypeId}, #{flightId}, #{ticketTypeName},#{tankType}, #{initPrice}, #{discount}, #{luggageWeight}, #{isCancel}, #{cancelRule})")
    boolean add(FlightTicketType flightTicketType) throws SQLException;

    /**
     * 根据ticketTypeId删除机票类型
     * @param ticketTypeId
     * @return
     * @throws SQLException
     */
    @Delete("delete from tb_flight_ticket_type where ticketTypeId=#{ticketTypeId}")
    boolean deleteByTicketTypeId(String ticketTypeId) throws SQLException;

    /**
     * 更新机票类型
     * @param flightTicketType
     * @return
     * @throws SQLException
     */
    @Update("update tb_flight_ticket_type set flightId=#{flightId}, ticketTypeName=#{ticketTypeName},tankType=#{tankType}, initPrice=#{initPrice}, discount=#{discount}, luggageWeight=#{luggageWeight}, isCancel=#{isCancel}, cancelRule=#{cancelRule} where ticketTypeId=#{ticketTypeId} ")
    boolean changeTicketTypeId(FlightTicketType flightTicketType) throws SQLException;

    /**
     * 查找所有机票类型信息
     * @return
     * @throws SQLException
     */
    @Select("select * from tb_flight_ticket_type")
    List<FlightTicketType> selectAll() throws SQLException;

    /**
     * 根据ticketTypeId查询机票类型信息
     * @param ticketTypeId
     * @return
     * @throws SQLException
     */
    @Select("select * from tb_flight_ticket_type where ticketTypeId=#{ticketTypeId}")
    FlightTicketType selectOne(String ticketTypeId) throws SQLException;
}
